clear
set more off
set mem 1g
# delimit ;
/*****************************************************************************************************************;
**This dofile starts from raw DHS data (DHS2004/BDKR4JDT/BDKR4JFL.DTA) and generates expandedDHSGPS_Mergedhh2004;

other pre-generated datasets this dofile also uses:
collapsedGPS2004
*****************************************************************************************************************/;

*****************************************************************************************************************;
*Paths;
*****************************************************************************************************************;

*access files in subdirectory generated by data creating dofiles;
local indataset "rawdta/DHS2004/BDKR4JDT/BDKR4JFL.DTA";

local outdataset "dtafiles/expandedDHSGPS_Mergedhh2004";

*****************************************************************************************************************;
*Main;
*****************************************************************************************************************;

use "`indataset'";

ren v001 dhsid04;
ren v007 year;

**HW: renames household/individual level variables**;
*breastfeeding variables;
ren s449a1 plainwater;
ren s449c1 babyformula;
ren s449e1 otherliq;
ren s449b1 sugarwater;
ren s449d1 cowgoat;
ren m4 durationbreast;
ren m5 monthsbreast;
ren hw1 childage;
ren b2 childbyear;

ren hw5 htasd;
ren hw11 wthtsd;

ren v113 watersource;
ren h11 diarrhea;

**HW: Assigns each observation to the cluster data and nearby well characteristics**;
merge m:1 dhsid04 using  "dtafiles/collapsedGPS2004.dta";
drop _merge;
save "`outdataset'",replace;


